/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package action.wadministration;

import static com.opensymphony.xwork2.Action.SUCCESS;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import database.StaffAuthenticationDAO;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import model.Shistory;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

/**
 *
 * @author Trang
 */
@Namespace("/Administration")
public class AdministrationAction extends ActionSupport{
    private List<Shistory> shistories = new ArrayList<Shistory>();
    private String keyword;
    public StaffAuthenticationDAO auDAO = new StaffAuthenticationDAO();
     

    public String getKeyword() {
        return keyword;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    public List<Shistory> getShistories() {
        return shistories;
    }

    public void setShistories(List<Shistory> shistories) {
        this.shistories = shistories;
    }
//    @Action(value = "sort-customer", results = {
//        @Result(name = "success", location = "/manageCustomer/w_customer.jsp")
//    })
    @Action(
            value="administration", results={
                @Result(name = "success", location ="/manageStaff/w_administration.jsp")
            })
    public String CatelogueManagement()
    {
        shistories = auDAO.getAllShistory();
        System.out.println(shistories.size());
        
        Map session = ActionContext.getContext().getSession();
        session.put("shistory", 1);
        Integer staff = (Integer) session.get("shistory");
         //Integer history = (Integer) session.getAttribute("history");
        System.out.print("result"+staff);
        
        //ListCategoriesWithParent = productDAO.getChildrenCategory();
        return SUCCESS;
    }
    @Action(
            value="searchHistory", results={
                @Result(name = "success", location ="/manageStaff/w_administration.jsp")
            })
    public String Search()
    {
        shistories = auDAO.SearchShistory(keyword);
        Map session = ActionContext.getContext().getSession();
        //ListCategoriesWithParent = productDAO.getChildrenCategory();
        //Map session = ActionContext.getContext().getSession();
        session.put("shistory", 2);
        return SUCCESS;
    }
    
}
